package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.admin.util.UploadUtil;
import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by 13925 on 2018/10/29.
 */

/**
 * 用户游记管理层
 */
@Controller
@RequestMapping("/strategyCatalog")
public class StrategyCatalogController {

    @Autowired
    IStrategyCatalogService strategyCatalogService;

    @Autowired
    IStrategyService strategyService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model) {
        PageInfo result = strategyCatalogService.query(qo);
        model.addAttribute("result", result);
        model.addAttribute("strategys", strategyService.selectAll());
        return "strategy/catalog";
    }

    @RequestMapping("/saveOrUpdate")
    public String saveOrUpdate(MultipartFile file, StrategyCatalog strategyCatalog) {
        strategyCatalogService.saveOrUpdate(strategyCatalog);
        return "redirect:/strategyCatalog/list.do";
    }


}
